package com.novelot.plugin.allinone.switc;

import com.novelot.plugin.allinone.util.ShellUtils;

public class SwitchBean {

    public String key;
    public boolean offon;
    public String cmdOn;
    public String cmdOff;
    private String path;

    public SwitchBean(String key, boolean offon, String cmdOn, String cmdOff, String path) {
        this.key = key;
        this.offon = offon;
        this.cmdOn = cmdOn;
        this.cmdOff = cmdOff;
        this.path = path;
    }

    public void update(boolean offon) {
        if (this.offon == offon) return;
        this.offon = offon;
        String p = path;
        String cmdChMod = "chmod 777 " + p;
        if (this.offon) {
            ShellUtils.runShells(cmdChMod, cmdOn);
        } else {
            ShellUtils.runShells(cmdChMod, cmdOff);
        }
    }
}
